package cn.edu.ldu.protocol;

import cn.edu.ldu.modules.controller.FriendsController;
import cn.edu.ldu.modules.entity.FriendsEntity;
import cn.edu.ldu.views.modules.controller.UserController;
import com.alibaba.fastjson.JSONObject;

import java.io.IOException;
import java.net.DatagramPacket;

public class DeleteFriend {

    public DeleteFriend(Protocol protocol){

        FriendsEntity friendsEntity = JSONObject.parseObject(protocol.getData(), FriendsEntity.class);

        try {

            String result = FriendsController.deleteFriend(friendsEntity, protocol.getToken());

            protocol.setKey(result);
            protocol.setData(null);
            UserController.sendDataToUser(protocol);

        } catch (Exception e) {
            e.printStackTrace();
        }


    }

}
